import enum
from enum import Enum


class Status(Enum):
    SUCCESS = 1
    OK = 1
    FAIL = 2
    WRONG = 2


# 加上这个装饰器，避免出现value相同的情况
# ValueError: duplicate values found in <enum 'Status2'>: OK -> SUCCESS, WRONG -> FAIL
@enum.unique
class Status2(Enum):
    SUCCESS = 1
    # OK = 1
    FAIL = 2
    # WRONG = 2


for s in Status:
    print(s)
# 相同的value，只有一个是主要的，其余的会变为别名
# Status.SUCCESS
# Status.FAIL

# 打印所有，包括别名
print(Status.__members__)
# {'SUCCESS': <Status.SUCCESS: 1>, 'OK': <Status.SUCCESS: 1>, 'FAIL': <Status.FAIL: 2>, 'WRONG': <Status.FAIL: 2>}

print(Status.SUCCESS == Status.OK)  # True
print(Status.SUCCESS is Status.OK)  # True



